<?php
/* @var $this KelompokController */
/* @var $model Kelompok */
/* @var $form CActiveForm */
$request = app()->request;
if ($request->enableCsrfValidation) {
    echo CHtml::metaTag($request->getCsrfToken(), 'csrf-token');
    echo CHtml::metaTag($request->csrfTokenName, 'csrf-param');
}
$isnew = $model->isNewRecord;
?>
<div class="form">
    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'kelompok-form',
        'enableAjaxValidation' => false,));
    ?>

    <?php echo $form->errorSummary($model); ?>
    <table border="0" cellpadding="0" cellspacing="0" id="id-form">
        <tr>
            <th valign="top">    <?php echo $form->labelEx($model, 'id_kabupaten'); ?></th>
            <td class="idform">
                <?php
                echo $form->dropDownList($model, 'id_kabupaten', $list_parent, array(
                    'empty' => '(Pilih Kabupaten)',
                    'style' => 'width:200px'));
                ?>
            </td>
            <td class="idform">
                <?php if ($model->hasErrors('id_kabupaten')) echo "<div class='error-left'></div>"; ?>
                <?php echo $form->error($model, 'id_kabupaten', array('class' => 'error-inner')); ?>
            </td>
        </tr>
        <tr>
            <th valign="top"><?php echo $model->getAttributeLabel('nama kelompok'); ?></th>
            <td class="idform">
                <?php echo $form->textField($model, 'nama_kelompok', array('size' => 60, 'maxlength' => 250));
                ?>
            </td>
            <td class="idform">
                <?php if ($model->hasErrors('nama_kelompok')) echo "<div class='error-left'></div>"; ?>
                <?php echo $form->error($model, 'nama_kelompok', array('class' => 'error-inner')); ?>
            </td>
        </tr>
        <?php if (!$model->isNewRecord) : ?>
            <tr>
                <th valign="top"><?php echo $model->getAttributeLabel('ketua'); ?></th>
                <td class="idform">
                    <?php echo $form->hiddenField($model, 'ketua'); ?>
                    <?php
                    $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
                        'name' => 'ketua_auto',
                        'source' => url('kelompok/getlistjamaah', array("id" => $model->id_kelompok)),
                        'value' => $model->ketua0 == null ? " " : $model->ketua0->nama, //$model->ketua0->nama,
                        'options' => array(
                            'showAnim' => 'fold',
                            'select' => 'js:function(event, ui){ jQuery("#' . CHtml::activeId($model, 'ketua') .
                            '").val(ui.item["id"]); }'),
                        'htmlOptions' => array('size' => '60')));
                    ?>
                </td>
                <td class="idform">
                    <?php if ($model->hasErrors('ketua')) echo "<div class='error-left'></div>"; ?>
                    <?php echo $form->error($model, 'ketua', array('class' => 'error-inner')); ?>
                </td>
            </tr>
            <tr>
                <th valign="top"><?php echo $model->getAttributeLabel('wakil_ketua'); ?></th>
                <td class="idform">
                    <?php echo $form->hiddenField($model, 'wakil_ketua'); ?>
                    <?php
                    $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
                        'name' => 'wakil_ketua_auto',
                        'source' => url('kelompok/getlistjamaah', array("id" => $model->id_kelompok)),
                        'value' => $model->wakilKetua == null ? " " : $model->wakilKetua->nama, //$model->wakilKetua->nama,
                        'options' => array(
                            'showAnim' => 'fold',
                            'select' => 'js:function(event, ui){ jQuery("#' . CHtml::activeId($model, 'wakil_ketua') .
                            '").val(ui.item["id"]); }'),
                        'htmlOptions' => array('size' => '60')));
                    ?>
                </td>
                <td class="idform">
                    <?php if ($model->hasErrors('wakil_ketua')) echo "<div class='error-left'></div>"; ?>
                    <?php echo $form->error($model, 'wakil_ketua', array('class' => 'error-inner')); ?>
                </td>
            </tr>
            <tr>
                <th valign="top"><?php echo $model->getAttributeLabel('imam'); ?></th>
                <td class="idform">
                    <?php echo $form->hiddenField($model, 'imam'); ?>
                    <?php
                    $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
                        'name' => 'imam_auto',
                        'source' => url('kelompok/getlistjamaah', array("id" => $model->id_kelompok)),
                        'value' => $model->imam0 == null ? " " : $model->imam0->nama, // $model->imam0->nama,
                        'options' => array(
                            'showAnim' => 'fold',
                            'select' => 'js:function(event, ui){ jQuery("#' . CHtml::activeId($model, 'imam') .
                            '").val(ui.item["id"]); }'),
                        'htmlOptions' => array('size' => '60')));
                    ?>
                </td>
                <td class="idform">
                    <?php if ($model->hasErrors('imam')) echo "<div class='error-left'></div>"; ?>
                    <?php echo $form->error($model, 'imam', array('class' => 'error-inner')); ?>
                </td>
            </tr>
            <tr>
                <th valign="top"><?php echo $model->getAttributeLabel('wakil_imam_1'); ?></th>
                <td class="idform">
                    <?php echo $form->hiddenField($model, 'wakil_imam_1'); ?>
                    <?php
                    $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
                        'name' => 'wakil_imam_1_auto',
                        'source' => url('kelompok/getlistjamaah', array("id" => $model->id_kelompok)),
                        'value' => $model->wakilImam1 == null ? " " : $model->wakilImam1->nama, //$model->wakilImam1->nama,
                        'options' => array(
                            'showAnim' => 'fold',
                            'select' => 'js:function(event, ui){ jQuery("#' . CHtml::activeId($model, 'wakil_imam_1') .
                            '").val(ui.item["id"]); }'),
                        'htmlOptions' => array('size' => '60')));
                    ?>
                </td>
                <td class="idform">
                    <?php if ($model->hasErrors('wakil_imam_1')) echo "<div class='error-left'></div>"; ?>
                    <?php echo $form->error($model, 'wakil_imam_1', array('class' => 'error-inner')); ?>
                </td>
            </tr>
            <tr>
                <th valign="top"><?php echo $model->getAttributeLabel('wakil_imam_2'); ?></th>
                <td class="idform">
                    <?php echo $form->hiddenField($model, 'wakil_imam_2'); ?>
                    <?php
                    $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
                        'name' => 'wakil_imam_2_auto',
                        'source' => url('kelompok/getlistjamaah', array("id" => $model->id_kelompok)),
                        'value' => $model->wakilImam2 == null ? " " : $model->wakilImam2->nama, //$model->wakilImam2->nama,
                        'options' => array(
                            'showAnim' => 'fold',
                            'select' => 'js:function(event, ui){ jQuery("#' . CHtml::activeId($model, 'wakil_imam_2') .
                            '").val(ui.item["id"]); }'),
                        'htmlOptions' => array('size' => '60')));
                    ?>
                </td>
                <td class="idform">
                    <?php if ($model->hasErrors('wakil_imam_2')) echo "<div class='error-left'></div>"; ?>
                    <?php echo $form->error($model, 'wakil_imam_2', array('class' => 'error-inner')); ?>
                </td>
            </tr>
        <?php endif; ?>
        <tr>
            <th valign="top"><?php echo $model->getAttributeLabel('keterangan'); ?></th>
            <td class="idform">
                <?php
//                $this->widget('ext.xheditor.XHeditor',array(
//                'model'=>$model,
//                'modelAttribute'=>'keterangan',
//                'config'=>array(
//                    'id'=>'xheditor_1',
//                    'tools'=>'mfull', // mini, simple, mfull, full or from XHeditor::$_tools, tool names are case sensitive
//                    'skin'=>'vista', // default, nostyle, o2007blue, o2007silver, vista
//                    'width'=>'740px',
//                    'height'=>'400px',
//                    'loadCSS'=>XHtml::cssUrl('editor.css'),
//                    'upImgUrl'=>$this->createUrl('request/uploadFile'),
//                    'upImgExt'=>'jpg,jpeg,gif,png',
//                ),
//            ));
                ?>
                <?php
                $this->widget('ext.tinymce.TinyMce', array(
                    'model' => $model,
                    'attribute' => 'keterangan',
                    'fileManager' => array(
                        'class' => 'ext.elFinder.TinyMceElFinder',
                        'connectorRoute' => 'elfinder/connector',),
                    'htmlOptions' => array('rows' => 6, 'cols' => 60,),));
                ?>
            </td>
            <td class="idform">
                <?php if ($model->hasErrors('keterangan')) echo "<div class='error-left'></div>"; ?>
                <?php echo $form->error($model, 'keterangan', array('class' => 'error-inner')); ?>
            </td>
        </tr>
        <tr>
            <th valign="top"><?php echo $model->getAttributeLabel('jenis_kelamin'); ?></th>
            <td valign="top">    <?php echo $form->radioButtonList($model, 'jenis_kelamin', array(0 => 'Pria', 1 => 'Wanita'));
                ?>
            </td>
              <td class="idform">
                <?php if ($model->hasErrors('jenis_kelamin')) echo "<div class='error-left'></div>"; ?>
                <?php echo $form->error($model, 'jenis_kelamin', array('class' => 'error-inner')); ?>
            </td>
        </tr>
        <? if (!$model->isNewRecord) : ?>
            <tr>
                <th>&nbsp;</th>
                <td valign="top">
                    <?php
                    echo l('Tambah Kegiatan', url('kegiatan/create', array('id' => $model->id_kelompok)));
                    $this->widget('zii.widgets.grid.CGridView', array(
                        'id' => 'kegiatan-kelompok-grid',
                        'dataProvider' => $model_kegiatan->search(),
                        'columns' => array(
                            //        'id_kegiatan',
                            'bentuk_kegiatan',
                            'tempat',
                            'waktu',
                            'gender',
                            'penceramah',
                            'kontak',
//        'id_kelompok',
                            'keterangan',
                            array(
                                'class' => 'CButtonColumn',
                            ),
                        ),
                    ));
                    ?>
                </td>
                <td class="idform"></td>
            </tr>
        <? endif; ?>
        <tr>
            <th>&nbsp;</th>
            <td valign="top">
                <?php echo CHtml::submitButton($model->isNewRecord ? 'Buat' : 'Simpan', array('class' => 'form-submit')); ?>
            </td>
            <td class="idform"></td>
        </tr>
    </table>
    <?php $this->endWidget(); ?>
</div><!-- form -->